package com.reggie.service.impl;

import com.reggie.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ShopServiceimpl implements ShopService {

    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 设置营业状态
     * @param status
     */
    @Override
    public void update(Integer status) {
        redisTemplate.opsForValue().set("KEY",status);
        log.info("设置店铺营业状态为：{}" , status == 1?"营业":"打烊");
    }

    /**
     * 获取营业状态
     */
    @Override
    public Integer findShopStatus() {
        return (Integer)redisTemplate.opsForValue().get("KEY");
    }
}
